package com.yjyw.tiexie.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class VPFragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragments;
    private List<String> list;

    public VPFragmentAdapter(FragmentManager fm, List<Fragment> fragmenlist) {
        super(fm);
        this.fragments = fragmenlist;
    }

    public void setFragments(List<Fragment> fragments) {
        this.fragments = fragments;
    }

    public VPFragmentAdapter(FragmentManager fm, List<Fragment> fragmenlist, List<String> list) {
        super(fm);
        this.fragments = fragmenlist;
        this.list = list;
    }

    @Override
    public Fragment getItem(int position) {

        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list==null?super.getPageTitle(position):list.get(position);
    }
    public List<Fragment> getFragmenlist() {
        return fragments;
    }
}



